package com.iot.ammeter.network

import java.lang.RuntimeException


// 响应 body
data class ResponseWrap<T : ResponseData>(
    val success: Boolean,
    val message: String,
    val code: String,
    val data: T?
)

// 响应 body -> data
interface ResponseData

interface MockResponse {

    fun ResponseData.asResponse(): ResponseWrap<ResponseData> {
        return ResponseWrap(
            success = true, message = "请求成功", code = "200", data = this
        )
    }

}

/**
 * 接口数据请求失败时（非网络原因）抛出异常
 */
class APIFailException(val code: String, message: String) : RuntimeException(message)